package com.example.panpan.customerManage.service;

import com.example.common.utils.IMap;
import com.example.panpan.customerManage.mapper.TcFeedbackMapper;
import com.example.panpan.customerManage.model.TcFeedback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class FeedbackService {
    @Autowired
    private TcFeedbackMapper tcFeedbackMapper;

    public List<IMap>getFeedbackList(IMap param){
        return tcFeedbackMapper.getFeedbackList(param);
    }
    public int updState(IMap param){
        TcFeedback tcFeedback = tcFeedbackMapper.selectByPrimaryKey(param.getString("feedbackId"));
        tcFeedback.setState("1");
        tcFeedbackMapper.updateByPrimaryKeySelective(tcFeedback);
        return 1;
    }
    public int addFeedback(IMap param){
        SimpleDateFormat tempDate = new SimpleDateFormat("yyyyMMddHHmmss");
        String datetime = tempDate.format(new Date());
        TcFeedback tcFeedback = new TcFeedback();
        tcFeedback.setFeedbackId("f"+datetime);
        tcFeedback.setFeedbackName(param.getString("feedbackName"));
        tcFeedback.setFeedbackInfo(param.getString("feedbackInfo"));
        tcFeedback.setFeedbackUser(param.getString("updateUser"));
        tcFeedback.setFeedbackDate(new Date());
        tcFeedback.setState("0");
        tcFeedbackMapper.insert(tcFeedback);
        return 1;
    }
}
